<script setup lang="ts">
import { onMounted } from 'vue'

// ChannelIO 类型声明
declare global {
  interface Window {
    ChannelIO?: (...args: any[]) => void
  }
}

// 打开 ChannelIO 聊天窗口
function openChannelIO() {
  if (window.ChannelIO) {
    window.ChannelIO('showMessenger')
  } else {
    console.warn('ChannelIO 尚未加载')
  }
}

onMounted(() => {
  // 确保 ChannelIO 已经加载
  if (window.ChannelIO) {
    console.log('ChannelIO 在线客服已加载')
  }
})
</script>

<template>
  <div class="fab-wrap">
    <button class="fab" @click="openChannelIO" title="온라인 고객 서비스">💬</button>
  </div>
</template>

<style scoped>
.fab-wrap {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1000;
}

.fab {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: #6366f1;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.25);
  transition: all 0.2s ease;
  font-size: 20px;
}

.fab:hover {
  background: #5856eb;
  transform: scale(1.05);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}

.fab:active {
  transform: scale(0.95);
}
</style>
